#ifndef TPGRAFICO_H_
#define TPGRAFICO_H_

#include <iostream>
#include <vector>
#include <X11/Xlib.h>   /* defines common Xlib functions and structs. */
#include <stdio.h>

#include "uRISC_Beta.h"

using namespace std;

class TpGrafico{
public:
	TpGrafico();
	~TpGrafico();
	void init(void);
	void create_simple_window(int x, int y);
	void create_gc(void);	
	void event(uRISC_Beta &uCPU);
	void dCaixa(void);
	void dReg(int x, int y, string vReg);
	void dRegDSize(int x, int y, string vReg);
	void dRegFile(int x, int y);
	void dMemROM(int x, int y);
	void dULA(int x, int y);
	void tpTela(void);
	void tpClearTela(void);
	void dRegIR(int x, int y);
	void dRegPC(int x, int y);
	void dRegFR(int x, int y);
	//relativos ao dados do uRISC
	void setVROMPushBack(string str);
	void setpcREG(u16bits pc) { pcREG = pc; }
	void setirREG(u16bits ir) { irREG = ir; }
	void setFlagN(int fl) { flag_N = fl; }
	void setFlagZ(int fl) { flag_Z = fl; }
	void setFlagNZ(int fl) { flag_NZ = fl; }
	void setFlagC(int fl) { flag_C = fl; }
	void setFlagO(int fl) { flag_O = fl; }
	void setFlagT(int fl) { flag_T = fl; }
	void setRegREG(u16bits r, int i){ regREG[i] = r; }
	void setRegA(int r) { regA = r; }
	void setRegB(int r) { regB = r; }
	void setRegALU(int r) { regALU = r; }
	void dpassoURISC(int x, int y);
	void tpAtualizaTela(uRISC_Beta &uCPU);
	void comandos(void){
		cout << endl;
		cout << "Modo Grafico: " << endl;
		cout << "                  [e] = Execucao ciclo a ciclo  " << endl;
		cout << "                  [r] = Execucao passo a passo  " << endl;
		cout << "                  [m] = Imprime regiao da memoria "<< endl;
		cout << "                  [q] = Sai do progama grafico    "<< endl;
		cout << endl;
	}

private:
	Display* display;	 // pointer to X Dispstatic lay structure.
	int screen_num;		 // number of screen to place the window on.
	Window win;			 // pointer to the newly created window.
	unsigned int display_width, display_height;  // height and width of the X display.
	unsigned int width, height;	 // height and width for the new window.
	char *display_name;  // address of the X display.
	GC gc;               // GC (graphics context) used for drawing.
	GC gc2;              // GC (graphics context) usado para escrever em "branco"
	XFontStruct* font_info;       /* Font structure, used for drawing text.    */
//	char* font_name = "*-helvetica-*-12-*"; /* font to use for drawing text.   */
	char* font_name;	
	XGCValues values;	
	int passoCiclo;
	
	//dados relativos ao uRISC
	vector<string> vROM;  //memoria para display grafico
	u16bits pcREG;
	u16bits irREG;
	u16bits regREG[8];
	u16bits regA;
	u16bits regB;
	u16bits regALU;
	int flag_N;
	int flag_Z;
	int flag_NZ;
	int flag_C;
	int flag_O;
	int flag_T;
	int viewOP;
};


#endif /*TPGRAFICO_H_*/
